<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../js/vue.min.js"></script>
    <script src="../js/axios.min.js"></script>
  </head>
  <body>
    <div id="app">
      <input type="text" name="id" v-model="id" />
      <input type="text" name="username" v-model="username" />
      <button type="button" @click="test1">测试1</button>
    </div>
  </body>
  <script>
    var app = new Vue({
      el: "#app",
      data: {
        id: "",
        username: "",
      },
      methods: {
        test1: function () {
          //发送异步请求
          //  axios.get(url).then(fn);
          //  axios.get(url,{}).then(fn)
          axios
            .post("http://localhost:8080/test1", {
              id: app.id,
              username: app.username,
            })
            .then(function (res) {
              console.log(res.data.data);
            });
        },
      },
    });
  </script>
</html>
